$("#data_form").show();


$("#serial_country").change(function(){
	//	alert('ph');
	var v=$("#serial_country").val();
	if(v=='PH')
	{	
	
			$("select#serial_user_region option[value=0]").attr('selected', 'selected');
			
			$("#serial_user_state").val('N/A');
			$("#regionholder").show();
			$("#stateholder").hide();
			
		
	}
	else
	{


		$("select#serial_user_region option[selected]").removeAttr("selected");
		$("select#serial_user_region option[value='Region1']").attr('selected', 'selected');
		
		$("#serial_user_state").val('');
		$("#regionholder").hide();
	
		$("#stateholder").show();
		
	}

	
});

jQuery.validator.addMethod("noNCR", function(value, element) {
    return this.optional(element) || (value != 'NCR');
}, "Content not Viewable for users from NCR");
jQuery.validator.addMethod("noZero", function(value, element) {
    return this.optional(element) || (value != 0);
}, "This field is Required");
	$("#data_form").validate({
			rules: {
				serial_first_name: "required",
				serial_last_name: "required",
				serial_user_address: "required",
				serial_user_city: "required",
				serial_user_state: "required",
				payment_method: "required",
				user_secret: "required",
				user_answer: "required",
				payment_method: "required",
				serial_country: {
					required: true,
					noZero : true
				},
				
				serial_user_region: {
					required: true,
					noNCR : true,
					noZero : true
				},
					user_password: {
						required: true,
						minlength: 5
					},
					confirm_password: {
						required: true,
						minlength: 5,
						equalTo: "#user_password"
					},
				user_email: {
					required: true,
					email: true,
					  remote:'admin/a/email_exists_check.php'  
				}
			
			},
			messages: {
			
				 user_email: {  
	                    remote:jQuery.format("This Email address has been used")
	                }
			}
		});
		
		$('#buy_submit').click(function(){

			//$('#buy_submit').attr('value','Please Wait');
			//$('#buy_submit').attr('disabled','disabled');
			
			//$('#data_form').submit();

		});